const countOptions = {
    //开启命名空间
    namespaced: true,    
    actions:{
        incrementOdd(context, value) {
            console.log('actions incrementOdd 执行了');
            if(context.state.sum % 2) {
                context.commit('increment', value)
            }
        },
        incrementWait(context, value) {
            console.log('actions incrementWait 执行了');
            setTimeout(() => {
                context.commit('increment', value)
            }, 1000);
        },
    },
    mutations:{
        //增加求和
        increment(state, value) {
            console.log('mutations increment 执行了');
            state.sum += value;
        },
        //减少求和
        decrement(state, value) {
            console.log('mutations decrement 执行了');
            state.sum -= value;
        },
    },
    state: {
        //当前求和
        sum: 0,
        school:'尚硅谷',
        subject:'前端',
    },
    getters: {
        bigSum(state) {
            return state.sum * 10;
        }
    }
}

export default countOptions;